package handler

import (
	"context"
	"main/domain/model"
	pb "main/proto"
)

type User struct {

}

func (u *User) Register(ctx context.Context, request *pb.UserRegisterRequest, response *pb.UserRegisterResponse) error {
	response.Message = "添加成功"
	return nil
}

func (u *User) Login(ctx context.Context, request *pb.UserLoginRequest, response *pb.UserLoginResponse) error {
	response.IsSuccess = true
	return nil
}

func (u *User) GetUserInfo(ctx context.Context, request *pb.UserInfoRequest, response *pb.UserInfoResponse) error {
	// 查数据, 返回结果
	user := &model.User{
		ID:           1,
		UserName:     "筱怪",
		FirstName:    "筱",
		HashPassword: "xxx",
	}
	
	SetUserResponse(user, response)
	return nil
}

func SetUserResponse(user *model.User, response *pb.UserInfoResponse) {
	response.UserId = user.ID
	response.UserName = user.UserName
	response.FirstName = user.FirstName
}
